package class

import (
	"fmt"
	"github.com/astaxie/beego/orm"
)

//定义Users表
type Users struct {
	Id       int `orm:"pk"` //设置为主键，字段Id，Password首字母必须大写
	Password string
}

//查询用户表
func (u *Users) ReadDB() (err error) {
	o := orm.NewOrm()
	err = o.Read(u)
	return err
}

//创建用户表
func (u *Users) Create() (err error) {
	o := orm.NewOrm()
	fmt.Println("Create success!")
	_, _ = o.Insert(u)
	return err
}

//更新用户表
func (u *Users) Update() (err error) {
	o := orm.NewOrm()
	_, err = o.Update(u)
	return err
}
